package cn.tedu.sjmall.stock1.service.impl;

import cn.tedu.sjmall.commons.pojo.stock.dto.StockReduceCountDTO;
import cn.tedu.sjmall.stock1.mapper.Stock1Mapper;
import cn.tedu.sjmall.stock1.service.IStock1Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class Stock1ServiceImpl implements IStock1Service {

    @Autowired
    private Stock1Mapper stockMapper;

    @Override
    public void reduceCommodityCount(StockReduceCountDTO stockReduceCountDTO) {
        // 调用持久层减少库存的方法
        // 参数1:商品编号
        // 参数2:减少的库存数
        stockMapper.updateStockByCommodityCode(
                stockReduceCountDTO.getCommodityCode(),
                stockReduceCountDTO.getReduceCount());
        log.info("库存减少完成!");

    }
}
